home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / cdgtst / hyperlin.h < prev    next >
C/C++ Source or Header  |  1997-11-22  |  3KB  |  94 lines

  1. // HyperLink.h : header file
  2. //
  3. //
  4. // HyperLink static control. Will open the default browser with the given URL
  5. // when the user clicks on the link.
  6. //
  7. // Copyright Chris Maunder, 1997
  8. // Feel free to use and distribute.
  9.  
  10. #if !defined(AFX_HYPERLINK_H__D1625061_574B_11D1_ABBA_00A0243D1382__INCLUDED_)
  11. #define AFX_HYPERLINK_H__D1625061_574B_11D1_ABBA_00A0243D1382__INCLUDED_
  12.  
  13. #if _MSC_VER >= 1000
  14. #pragma once
  15. #endif // _MSC_VER >= 1000
  16.  
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CHyperLink window
  19.  
  20. class CHyperLink : public CStatic
  21. {
  22. // Construction/destruction
  23. public:
  24.     CHyperLink();
  25.     virtual ~CHyperLink();
  26.  
  27. // Attributes
  28. public:
  29.  
  30. // Operations
  31. public:
  32.  
  33.     void SetURL(CString strURL);
  34.     CString GetURL()            { return m_strURL;   }
  35.  
  36.     void SetColours(COLORREF crLinkColour, COLORREF crVisitedColour);
  37.     COLORREF GetLinkColour()    { return m_crLinkColour; }
  38.     COLORREF GetVisitedColour()    { return m_crVisitedColour; }
  39.  
  40.     void SetVisited(BOOL bVisited = TRUE);
  41.     BOOL GetVisited()            { return m_bVisited; }
  42.  
  43.     void SetLinkCursor(HCURSOR hCursor) { m_hLinkCursor = hCursor; }
  44.  
  45.     void SetUnderline(BOOL bUnderline = TRUE);
  46.     BOOL GetUnderline()            { return m_bUnderline; }
  47.  
  48.     void SetAutoSize(BOOL bAutoSize = TRUE);
  49.     BOOL GetAutoSize()            { return m_bAdjustToFit; }
  50.  
  51. // Overrides
  52.     // ClassWizard generated virtual function overrides
  53.     //{{AFX_VIRTUAL(CHyperLink)
  54.     public:
  55.     virtual BOOL PreTranslateMessage(MSG* pMsg);
  56.     protected:
  57.     virtual void PreSubclassWindow();
  58.     //}}AFX_VIRTUAL
  59.  
  60. // Implementation
  61. protected:
  62.     HINSTANCE GotoURL(LPCTSTR url, int showcmd);
  63.     void ReportError(int nError);
  64.     LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata);
  65.     void PositionWindow();
  66.  
  67. // Protected attributes
  68. protected:
  69.     COLORREF m_crLinkColour, m_crVisitedColour;        // Hyperlink colours
  70.     BOOL     m_bVisited;                            // Has it been visited?
  71.     BOOL     m_bUnderline;                            // underline hyperlink?
  72.     BOOL     m_bAdjustToFit;                        // Adjust window size to fit text?
  73.     CString  m_strURL;                                // hyperlink URL
  74.     CFont     m_Font;                                // Underline font if necessary
  75.     HCURSOR  m_hLinkCursor;                            // Cursor for hyperlink
  76.     CToolTipCtrl m_ToolTip;                            // The tooltip
  77.  
  78.     // Generated message map functions
  79. protected:
  80.     //{{AFX_MSG(CHyperLink)
  81.     afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
  82.     afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
  83.     //}}AFX_MSG
  84.     afx_msg void OnClicked();
  85.     DECLARE_MESSAGE_MAP()
  86. };
  87.  
  88. /////////////////////////////////////////////////////////////////////////////
  89.  
  90. //{{AFX_INSERT_LOCATION}}
  91. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  92.  
  93. #endif // !defined(AFX_HYPERLINK_H__D1625061_574B_11D1_ABBA_00A0243D1382__INCLUDED_)
  94.